<template>
	<view class="content">
		<!-- #ifdef H5 || APP-PLUS -->
		<view class="message-title">
			<commonTitle :title="title"></commonTitle>
		</view>
		<!-- #endif -->
		<view class="list-scroll-content nopadding">
			<!-- 背景图 -->
			<image src="../../static/common/newDriver-bg.png" class="newDriver-bg"></image>
			<!-- 常见问题 -->
			<view class="question" style="margin-top: 36upx;">{{title}}</view>
			<view class="question-block">
				<uni-collapse accordion="true">
						<uni-collapse-item 
						:title="question.helpName"
							v-for="(question,index) in questionList" :key="index"
						>
							<view class="answer">
								<jyf-parser :html="question.content"  lazy-load ref="article" selectable
								 show-with-animation use-anchor @error="error" @imgtap="imgtap" @linkpress="linkpress" @ready="ready">加载中...</jyf-parser>
							</view>
						</uni-collapse-item>
				</uni-collapse>
			</view>
		</view>	
		
	</view>
</template>

<script>
	import commonTitle from'../../components/titile/title.vue'
	import uniCollapse from '../../components/uni-collapse/uni-collapse.vue'
	import uniCollapseItem from '../../components/uni-collapse-item/uni-collapse-item.vue'
	import jyfParser from '../../components/jyf-parser/jyf-parser.vue';
	export default{
		name:"signIn",
		data(){
			return{
				title:'',
				id:0,
				questionList:[],
				doAnimate:false,
				currentIndex:0,
				apptoken:""
			}
		},
		components:{
			commonTitle,
			uniCollapse,
			uniCollapseItem,
			jyfParser
		},
		onLoad(option){
			this.apptoken = uni.getStorageSync('apptoken');
			this.id = option.id;
			this.getQuestions(this.id);
			this.getquestionList(this.id);
			
		},
		methods:{
			hahha(n){
				this.currentIndex = n;
			},
			getQuestions(id){
				this.title = this.$CommonJS.getQuestionTitle(id);
			},
			getquestionList(id){
				//问题列表
				const _this = this;
				uni.request({
					url:this.$API.URL + this.$API.help,
					data:{"helpType":id},
					success(res){
						if(res.data.success){
							_this.questionList = res.data.data;
							// this.questionList.map(item => {
							// 	item.isClick = false
							// })
							console.log(this.questionList)
						}
						console.log(res)
					},
					fail(res){
						uni.showToast({
							title:res.msg
						})
						console.log(res)
					}
				})
			},
			ready(e) {
				console.log('ready', e);
				// console.log('api: getText', this.$refs.article.getText());
				console.log('imgList', this.$refs.article.imgList);
			},
			imgtap(e) {
				console.log('imgtap', e);
			},
			linkpress(e) {
				console.log('linkpress', e);
			},
			error(e) {
				console.error(e);
			}
			
		}
	}
</script>

<style>
	@import url("newDriver.css");
</style>
